package com.camunda.workflow.controller.task.message;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * 发送任务
 */
@Slf4j
@Component("sendTask")
public class SendTask implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) throws Exception {
        log.info("sendTask发送消息");
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        // Message_Received_Task_Test 是 接收任务中的 message->Global message reference name
        // message_business_key 是 接收任务中的 business key
        runtimeService.createMessageCorrelation("Message_Received_Task_Test")
                .processInstanceBusinessKey("message_business_key")
                .correlate();
    }
}
